package com.fast.manager.base.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import org.apache.shiro.crypto.SecureRandomNumberGenerator;

import com.alibaba.fastjson.annotation.JSONField;
import com.fast.commons.repository.BaseModel;
import com.fast.commons.utils.PropertyUtils;

public class User extends BaseModel implements Serializable {
	private static final long serialVersionUID = 1L;
	
	private static String applicationSalt = PropertyUtils.getValue("shiro.applicationSalt");

	private Long id;

	private Long company_id;

    private Long dept_id;
	
    private String code;

    private String account;

    private String password;

    private String securitySalt;

    private String truename;

    private String spell;

    private String gender;

    @JSONField(format="yyyy-MM-dd")
    private Date birthday;

    private String mobile;

    private String telephone;

    private String email;

    private Date changePasswordDate;

    private Integer logOnCount;

    private Date firstVisit;

    private Date previousVisit;

    private Date lastVisit;

    private String remark;

    private Integer locked;

    private String iforgot_signature;

    private Date iforgot_outDatetime;

    private String openid;
    
    private Date createTime;

    private Long createUserId;

    private String createUserName;

    private Date modifyTime;

    private Long modifyUserId;

    private String modifyUserName;
    
    /*******************业务属性*********************/
    
    private Company company ;
    
    private Dept dept ;
    
    private List<Role> roles ;
    
    private List<RoleMenu> rolesMenu ;
    
    
    /**
     * 加密盐
     */
    public void SecurityRandomSalt() {
        setSecuritySalt(new SecureRandomNumberGenerator().nextBytes().toHex());
    }
    
    /**
     * 组合加密盐
     * @return
     */
    public String getCredentialsSalt() {
    	if(null != getSecuritySalt()) {
    		return applicationSalt + account + getSecuritySalt() ;
    	} 
    	return null;
	}
    

	public List<RoleMenu> getRolesMenu() {
		return rolesMenu;
	}

	public void setRolesMenu(List<RoleMenu> rolesMenu) {
		this.rolesMenu = rolesMenu;
	}

	public List<Role> getRoles() {
		return roles;
	}

	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}

	public Company getCompany() {
		return company;
	}

	public void setCompany(Company company) {
		this.company = company;
	}

	public Dept getDept() {
		return dept;
	}

	public void setDept(Dept dept) {
		this.dept = dept;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Long getCreateUserId() {
		return createUserId;
	}

	public Long getCompany_id() {
		return company_id;
	}

	public void setCompany_id(Long company_id) {
		this.company_id = company_id;
	}

	public Long getDept_id() {
		return dept_id;
	}

	public void setDept_id(Long dept_id) {
		this.dept_id = dept_id;
	}

	public String getOpenid() {
		return openid;
	}

	public void setOpenid(String openid) {
		this.openid = openid;
	}

	public void setCreateUserId(Long createUserId) {
		this.createUserId = createUserId;
	}

	public String getCreateUserName() {
		return createUserName;
	}

	public void setCreateUserName(String createUserName) {
		this.createUserName = createUserName;
	}

	public Date getModifyTime() {
		return modifyTime;
	}

	public void setModifyTime(Date modifyTime) {
		this.modifyTime = modifyTime;
	}

	public Long getModifyUserId() {
		return modifyUserId;
	}

	public void setModifyUserId(Long modifyUserId) {
		this.modifyUserId = modifyUserId;
	}

	public String getModifyUserName() {
		return modifyUserName;
	}

	public void setModifyUserName(String modifyUserName) {
		this.modifyUserName = modifyUserName;
	}

	public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code == null ? null : code.trim();
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account == null ? null : account.trim();
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password == null ? null : password.trim();
    }

    public static String getApplicationSalt() {
		return applicationSalt;
	}

	public static void setApplicationSalt(String applicationSalt) {
		User.applicationSalt = applicationSalt;
	}

	public String getSecuritySalt() {
		return securitySalt;
	}

	public void setSecuritySalt(String securitySalt) {
		this.securitySalt = securitySalt;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public String getTruename() {
        return truename;
    }

    public void setTruename(String truename) {
        this.truename = truename == null ? null : truename.trim();
    }

    public String getSpell() {
        return spell;
    }

    public void setSpell(String spell) {
        this.spell = spell == null ? null : spell.trim();
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender == null ? null : gender.trim();
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile == null ? null : mobile.trim();
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone == null ? null : telephone.trim();
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email == null ? null : email.trim();
    }

    public Date getChangePasswordDate() {
        return changePasswordDate;
    }

    public void setChangePasswordDate(Date changePasswordDate) {
        this.changePasswordDate = changePasswordDate;
    }

    public Integer getLogOnCount() {
        return logOnCount;
    }

    public void setLogOnCount(Integer logOnCount) {
        this.logOnCount = logOnCount;
    }

    public Date getFirstVisit() {
        return firstVisit;
    }

    public void setFirstVisit(Date firstVisit) {
        this.firstVisit = firstVisit;
    }

    public Date getPreviousVisit() {
        return previousVisit;
    }

    public void setPreviousVisit(Date previousVisit) {
        this.previousVisit = previousVisit;
    }

    public Date getLastVisit() {
        return lastVisit;
    }

    public void setLastVisit(Date lastVisit) {
        this.lastVisit = lastVisit;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark == null ? null : remark.trim();
    }

    public Integer getLocked() {
        return locked;
    }

    public void setLocked(Integer locked) {
        this.locked = locked;
    }

	public String getIforgot_signature() {
		return iforgot_signature;
	}

	public void setIforgot_signature(String iforgot_signature) {
		this.iforgot_signature = iforgot_signature;
	}

	public Date getIforgot_outDatetime() {
		return iforgot_outDatetime;
	}

	public void setIforgot_outDatetime(Date iforgot_outDatetime) {
		this.iforgot_outDatetime = iforgot_outDatetime;
	}

}